/*     */ package com.zimbra.cs.util;
/*     */ 
/*     */ import com.zimbra.common.httpclient.HttpClientUtil;
/*     */ import com.zimbra.common.localconfig.DebugConfig;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.WebSplitUtil;
/*     */ import com.zimbra.common.util.ZimbraHttpConnectionManager;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.AuthToken;
/*     */ import com.zimbra.cs.account.AuthTokenException;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.httpclient.HttpProxyUtil;
/*     */ import com.zimbra.cs.httpclient.URLUtil;
/*     */ import com.zimbra.cs.service.AuthProvider;
/*     */ import java.io.ByteArrayInputStream;
/*     */ import java.io.IOException;
/*     */ import java.util.Collections;
/*     */ import java.util.List;
/*     */ import org.apache.commons.httpclient.HttpClient;
/*     */ import org.apache.commons.httpclient.HttpMethod;
/*     */ import org.apache.commons.httpclient.methods.GetMethod;
/*     */ import org.apache.commons.httpclient.methods.PostMethod;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WebClientServiceUtil
/*     */ {
/*     */   public static final String PARAM_AUTHTOKEN = "authtoken";
/*     */   private static final String FLUSH_UISTRINGS_ON_UI_NODE = "/fromservice/flushuistrings";
/*     */   
/*     */   public static boolean isServerInSplitMode()
/*     */   {
/*  57 */     return (DebugConfig.debugLocalSplit) || (WebSplitUtil.isZimbraServiceSplitEnabled());
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public static void sendServiceRequestToEveryUiNode(String serviceUrl)
/*     */     throws ServiceException
/*     */   {
/*  66 */     List<Server> servers = Provisioning.getInstance().getAllServers("zimbra");
/*  67 */     if ((servers == null) || (servers.isEmpty())) {
/*  68 */       servers.add(Provisioning.getInstance().getLocalServer());
/*     */     }
/*  70 */     AuthToken authToken = AuthProvider.getAdminAuthToken();
/*  71 */     ZimbraLog.misc.debug("got admin auth token");
/*     */     
/*  73 */     HttpClient client = ZimbraHttpConnectionManager.getExternalHttpConnMgr().newHttpClient();
/*  74 */     HttpProxyUtil.configureProxy(client);
/*  75 */     for (Server server : servers) {
/*  76 */       if (isServerAtLeast8dot5(server)) {
/*  77 */         HttpMethod method = null;
/*     */         try {
/*  79 */           method = new GetMethod(URLUtil.getServiceURL(server, serviceUrl, false));
/*  80 */           ZimbraLog.misc.debug("connecting to ui node %s", new Object[] { server.getName() });
/*     */           try {
/*  82 */             method.addRequestHeader("authtoken", authToken.getEncoded());
/*     */           } catch (AuthTokenException e) {
/*  84 */             ZimbraLog.misc.warn(e);
/*     */           }
/*  86 */           int respCode = HttpClientUtil.executeMethod(client, method);
/*  87 */           if (respCode != 200) {
/*  88 */             ZimbraLog.misc.warn("service failed, return code: %d", new Object[] { Integer.valueOf(respCode) });
/*     */           }
/*     */         } catch (Exception e) {
/*  91 */           ZimbraLog.misc.warn("service failed for node %s", server.getName(), e);
/*     */         } finally {
/*  93 */           if (method != null) {
/*  94 */             method.releaseConnection();
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/*  99 */     if ((authToken != null) && (authToken.isRegistered())) {
/*     */       try {
/* 101 */         authToken.deRegister();
/* 102 */         ZimbraLog.misc.debug("de-registered auth token, isRegistered?%s", new Object[] { Boolean.valueOf(authToken.isRegistered()) });
/*     */       } catch (AuthTokenException e) {
/* 104 */         ZimbraLog.misc.warn("failed to de-register auth token", e);
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static String sendServiceRequestToOneRandomUiNode(String serviceUrl)
/*     */     throws ServiceException
/*     */   {
/* 116 */     return sendServiceRequestToOneRandomUiNode(serviceUrl, Collections.emptyMap());
/*     */   }
/*     */   
/*     */   /* Error */
/*     */   public static String sendServiceRequestToOneRandomUiNode(String serviceUrl, java.util.Map<String, String> reqHeaders)
/*     */     throws ServiceException
/*     */   {
/*     */     // Byte code:
/*     */     //   0: invokestatic 4	com/zimbra/cs/account/Provisioning:getInstance	()Lcom/zimbra/cs/account/Provisioning;
/*     */     //   3: ldc 5
/*     */     //   5: invokevirtual 6	com/zimbra/cs/account/Provisioning:getAllServers	(Ljava/lang/String;)Ljava/util/List;
/*     */     //   8: astore_2
/*     */     //   9: aload_2
/*     */     //   10: ifnull +12 -> 22
/*     */     //   13: aload_2
/*     */     //   14: invokeinterface 7 1 0
/*     */     //   19: ifeq +16 -> 35
/*     */     //   22: aload_2
/*     */     //   23: invokestatic 4	com/zimbra/cs/account/Provisioning:getInstance	()Lcom/zimbra/cs/account/Provisioning;
/*     */     //   26: invokevirtual 8	com/zimbra/cs/account/Provisioning:getLocalServer	()Lcom/zimbra/cs/account/Server;
/*     */     //   29: invokeinterface 9 2 0
/*     */     //   34: pop
/*     */     //   35: invokestatic 14	com/zimbra/common/util/ZimbraHttpConnectionManager:getExternalHttpConnMgr	()Lcom/zimbra/common/util/ZimbraHttpConnectionManager;
/*     */     //   38: invokevirtual 15	com/zimbra/common/util/ZimbraHttpConnectionManager:newHttpClient	()Lorg/apache/commons/httpclient/HttpClient;
/*     */     //   41: astore_3
/*     */     //   42: aload_3
/*     */     //   43: invokestatic 16	com/zimbra/cs/httpclient/HttpProxyUtil:configureProxy	(Lorg/apache/commons/httpclient/HttpClient;)V
/*     */     //   46: invokestatic 10	com/zimbra/cs/service/AuthProvider:getAdminAuthToken	()Lcom/zimbra/cs/account/AuthToken;
/*     */     //   49: astore 4
/*     */     //   51: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   54: ldc 12
/*     */     //   56: invokevirtual 13	com/zimbra/common/util/Log:debug	(Ljava/lang/Object;)V
/*     */     //   59: ldc 50
/*     */     //   61: astore 5
/*     */     //   63: aload_2
/*     */     //   64: invokeinterface 17 1 0
/*     */     //   69: astore 6
/*     */     //   71: aload 6
/*     */     //   73: invokeinterface 18 1 0
/*     */     //   78: ifeq +316 -> 394
/*     */     //   81: aload 6
/*     */     //   83: invokeinterface 19 1 0
/*     */     //   88: checkcast 20	com/zimbra/cs/account/Server
/*     */     //   91: astore 7
/*     */     //   93: aload 7
/*     */     //   95: invokestatic 21	com/zimbra/cs/util/WebClientServiceUtil:isServerAtLeast8dot5	(Lcom/zimbra/cs/account/Server;)Z
/*     */     //   98: ifeq +293 -> 391
/*     */     //   101: aconst_null
/*     */     //   102: astore 8
/*     */     //   104: new 22	org/apache/commons/httpclient/methods/GetMethod
/*     */     //   107: dup
/*     */     //   108: aload 7
/*     */     //   110: aload_0
/*     */     //   111: iconst_0
/*     */     //   112: invokestatic 23	com/zimbra/cs/httpclient/URLUtil:getServiceURL	(Lcom/zimbra/cs/account/Server;Ljava/lang/String;Z)Ljava/lang/String;
/*     */     //   115: invokespecial 24	org/apache/commons/httpclient/methods/GetMethod:<init>	(Ljava/lang/String;)V
/*     */     //   118: astore 8
/*     */     //   120: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   123: ldc 25
/*     */     //   125: iconst_1
/*     */     //   126: anewarray 26	java/lang/Object
/*     */     //   129: dup
/*     */     //   130: iconst_0
/*     */     //   131: aload 7
/*     */     //   133: invokevirtual 27	com/zimbra/cs/account/Server:getName	()Ljava/lang/String;
/*     */     //   136: aastore
/*     */     //   137: invokevirtual 28	com/zimbra/common/util/Log:debug	(Ljava/lang/String;[Ljava/lang/Object;)V
/*     */     //   140: aload 8
/*     */     //   142: ldc 29
/*     */     //   144: aload 4
/*     */     //   146: invokevirtual 30	com/zimbra/cs/account/AuthToken:getEncoded	()Ljava/lang/String;
/*     */     //   149: invokeinterface 31 3 0
/*     */     //   154: aload_1
/*     */     //   155: invokeinterface 51 1 0
/*     */     //   160: invokeinterface 52 1 0
/*     */     //   165: astore 9
/*     */     //   167: aload 9
/*     */     //   169: invokeinterface 18 1 0
/*     */     //   174: ifeq +77 -> 251
/*     */     //   177: aload 9
/*     */     //   179: invokeinterface 19 1 0
/*     */     //   184: checkcast 53	java/util/Map$Entry
/*     */     //   187: astore 10
/*     */     //   189: aload 8
/*     */     //   191: aload 10
/*     */     //   193: invokeinterface 54 1 0
/*     */     //   198: checkcast 55	java/lang/String
/*     */     //   201: aload 10
/*     */     //   203: invokeinterface 56 1 0
/*     */     //   208: checkcast 55	java/lang/String
/*     */     //   211: invokeinterface 31 3 0
/*     */     //   216: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   219: ldc 57
/*     */     //   221: iconst_2
/*     */     //   222: anewarray 26	java/lang/Object
/*     */     //   225: dup
/*     */     //   226: iconst_0
/*     */     //   227: aload 10
/*     */     //   229: invokeinterface 54 1 0
/*     */     //   234: aastore
/*     */     //   235: dup
/*     */     //   236: iconst_1
/*     */     //   237: aload 10
/*     */     //   239: invokeinterface 56 1 0
/*     */     //   244: aastore
/*     */     //   245: invokevirtual 28	com/zimbra/common/util/Log:debug	(Ljava/lang/String;[Ljava/lang/Object;)V
/*     */     //   248: goto -81 -> 167
/*     */     //   251: aload_3
/*     */     //   252: aload 8
/*     */     //   254: invokestatic 34	com/zimbra/common/httpclient/HttpClientUtil:executeMethod	(Lorg/apache/commons/httpclient/HttpClient;Lorg/apache/commons/httpclient/HttpMethod;)I
/*     */     //   257: istore 9
/*     */     //   259: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   262: ldc 58
/*     */     //   264: iconst_1
/*     */     //   265: anewarray 26	java/lang/Object
/*     */     //   268: dup
/*     */     //   269: iconst_0
/*     */     //   270: iload 9
/*     */     //   272: invokestatic 36	java/lang/Integer:valueOf	(I)Ljava/lang/Integer;
/*     */     //   275: aastore
/*     */     //   276: invokevirtual 28	com/zimbra/common/util/Log:debug	(Ljava/lang/String;[Ljava/lang/Object;)V
/*     */     //   279: aload 8
/*     */     //   281: invokeinterface 59 1 0
/*     */     //   286: astore 5
/*     */     //   288: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   291: ldc 60
/*     */     //   293: iconst_1
/*     */     //   294: anewarray 26	java/lang/Object
/*     */     //   297: dup
/*     */     //   298: iconst_0
/*     */     //   299: aload 5
/*     */     //   301: aastore
/*     */     //   302: invokevirtual 28	com/zimbra/common/util/Log:debug	(Ljava/lang/String;[Ljava/lang/Object;)V
/*     */     //   305: aload 8
/*     */     //   307: ifnull +87 -> 394
/*     */     //   310: aload 8
/*     */     //   312: invokeinterface 38 1 0
/*     */     //   317: goto +77 -> 394
/*     */     //   320: astore 9
/*     */     //   322: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   325: ldc 62
/*     */     //   327: aload 9
/*     */     //   329: invokevirtual 47	com/zimbra/common/util/Log:warn	(Ljava/lang/Object;Ljava/lang/Throwable;)V
/*     */     //   332: aload 8
/*     */     //   334: ifnull +57 -> 391
/*     */     //   337: aload 8
/*     */     //   339: invokeinterface 38 1 0
/*     */     //   344: goto +47 -> 391
/*     */     //   347: astore 9
/*     */     //   349: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   352: ldc 63
/*     */     //   354: aload 9
/*     */     //   356: invokevirtual 47	com/zimbra/common/util/Log:warn	(Ljava/lang/Object;Ljava/lang/Throwable;)V
/*     */     //   359: aload 8
/*     */     //   361: ifnull +30 -> 391
/*     */     //   364: aload 8
/*     */     //   366: invokeinterface 38 1 0
/*     */     //   371: goto +20 -> 391
/*     */     //   374: astore 11
/*     */     //   376: aload 8
/*     */     //   378: ifnull +10 -> 388
/*     */     //   381: aload 8
/*     */     //   383: invokeinterface 38 1 0
/*     */     //   388: aload 11
/*     */     //   390: athrow
/*     */     //   391: goto -320 -> 71
/*     */     //   394: aload 4
/*     */     //   396: ifnull +54 -> 450
/*     */     //   399: aload 4
/*     */     //   401: invokevirtual 42	com/zimbra/cs/account/AuthToken:isRegistered	()Z
/*     */     //   404: ifeq +46 -> 450
/*     */     //   407: aload 4
/*     */     //   409: invokevirtual 43	com/zimbra/cs/account/AuthToken:deRegister	()V
/*     */     //   412: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   415: ldc 44
/*     */     //   417: iconst_1
/*     */     //   418: anewarray 26	java/lang/Object
/*     */     //   421: dup
/*     */     //   422: iconst_0
/*     */     //   423: aload 4
/*     */     //   425: invokevirtual 42	com/zimbra/cs/account/AuthToken:isRegistered	()Z
/*     */     //   428: invokestatic 45	java/lang/Boolean:valueOf	(Z)Ljava/lang/Boolean;
/*     */     //   431: aastore
/*     */     //   432: invokevirtual 28	com/zimbra/common/util/Log:debug	(Ljava/lang/String;[Ljava/lang/Object;)V
/*     */     //   435: goto +15 -> 450
/*     */     //   438: astore 6
/*     */     //   440: getstatic 11	com/zimbra/common/util/ZimbraLog:misc	Lcom/zimbra/common/util/Log;
/*     */     //   443: ldc 64
/*     */     //   445: aload 6
/*     */     //   447: invokevirtual 47	com/zimbra/common/util/Log:warn	(Ljava/lang/Object;Ljava/lang/Throwable;)V
/*     */     //   450: aload 5
/*     */     //   452: areturn
/*     */     // Line number table:
/*     */     //   Java source line #127	-> byte code offset #0
/*     */     //   Java source line #128	-> byte code offset #9
/*     */     //   Java source line #129	-> byte code offset #22
/*     */     //   Java source line #131	-> byte code offset #35
/*     */     //   Java source line #132	-> byte code offset #42
/*     */     //   Java source line #133	-> byte code offset #46
/*     */     //   Java source line #134	-> byte code offset #51
/*     */     //   Java source line #135	-> byte code offset #59
/*     */     //   Java source line #136	-> byte code offset #63
/*     */     //   Java source line #137	-> byte code offset #93
/*     */     //   Java source line #138	-> byte code offset #101
/*     */     //   Java source line #140	-> byte code offset #104
/*     */     //   Java source line #141	-> byte code offset #120
/*     */     //   Java source line #142	-> byte code offset #140
/*     */     //   Java source line #144	-> byte code offset #154
/*     */     //   Java source line #145	-> byte code offset #189
/*     */     //   Java source line #146	-> byte code offset #216
/*     */     //   Java source line #147	-> byte code offset #248
/*     */     //   Java source line #148	-> byte code offset #251
/*     */     //   Java source line #149	-> byte code offset #259
/*     */     //   Java source line #150	-> byte code offset #279
/*     */     //   Java source line #151	-> byte code offset #288
/*     */     //   Java source line #158	-> byte code offset #305
/*     */     //   Java source line #159	-> byte code offset #310
/*     */     //   Java source line #153	-> byte code offset #320
/*     */     //   Java source line #154	-> byte code offset #322
/*     */     //   Java source line #158	-> byte code offset #332
/*     */     //   Java source line #159	-> byte code offset #337
/*     */     //   Java source line #155	-> byte code offset #347
/*     */     //   Java source line #156	-> byte code offset #349
/*     */     //   Java source line #158	-> byte code offset #359
/*     */     //   Java source line #159	-> byte code offset #364
/*     */     //   Java source line #158	-> byte code offset #374
/*     */     //   Java source line #159	-> byte code offset #381
/*     */     //   Java source line #163	-> byte code offset #391
/*     */     //   Java source line #164	-> byte code offset #394
/*     */     //   Java source line #166	-> byte code offset #407
/*     */     //   Java source line #167	-> byte code offset #412
/*     */     //   Java source line #170	-> byte code offset #435
/*     */     //   Java source line #168	-> byte code offset #438
/*     */     //   Java source line #169	-> byte code offset #440
/*     */     //   Java source line #172	-> byte code offset #450
/*     */     // Local variable table:
/*     */     //   start	length	slot	name	signature
/*     */     //   0	453	0	serviceUrl	String
/*     */     //   0	453	1	reqHeaders	java.util.Map<String, String>
/*     */     //   8	56	2	servers	List<Server>
/*     */     //   41	211	3	client	HttpClient
/*     */     //   49	375	4	authToken	AuthToken
/*     */     //   61	390	5	resp	String
/*     */     //   69	13	6	i$	java.util.Iterator
/*     */     //   438	8	6	e	AuthTokenException
/*     */     //   91	41	7	server	Server
/*     */     //   102	280	8	method	HttpMethod
/*     */     //   165	13	9	i$	java.util.Iterator
/*     */     //   257	14	9	result	int
/*     */     //   320	8	9	e	IOException
/*     */     //   347	8	9	e	AuthTokenException
/*     */     //   187	51	10	entry	java.util.Map.Entry<String, String>
/*     */     //   374	15	11	localObject	Object
/*     */     // Exception table:
/*     */     //   from	to	target	type
/*     */     //   104	305	320	java/io/IOException
/*     */     //   104	305	347	com/zimbra/cs/account/AuthTokenException
/*     */     //   104	305	374	finally
/*     */     //   320	332	374	finally
/*     */     //   347	359	374	finally
/*     */     //   374	376	374	finally
/*     */     //   407	435	438	com/zimbra/cs/account/AuthTokenException
/*     */   }
/*     */   
/*     */   public static String sendServiceRequestToUiNode(Server server, String serviceUrl)
/*     */     throws ServiceException
/*     */   {
/* 176 */     if (isServerAtLeast8dot5(server)) {
/* 177 */       HttpClient client = ZimbraHttpConnectionManager.getExternalHttpConnMgr().newHttpClient();
/* 178 */       HttpProxyUtil.configureProxy(client);
/* 179 */       AuthToken authToken = AuthProvider.getAdminAuthToken();
/* 180 */       ZimbraLog.misc.debug("got admin auth token");
/* 181 */       String resp = "";
/* 182 */       HttpMethod method = null;
/*     */       try {
/* 184 */         method = new GetMethod(URLUtil.getServiceURL(server, serviceUrl, false));
/* 185 */         ZimbraLog.misc.debug("connecting to ui node %s", new Object[] { server.getName() });
/* 186 */         method.addRequestHeader("authtoken", authToken.getEncoded());
/* 187 */         int result = HttpClientUtil.executeMethod(client, method);
/* 188 */         ZimbraLog.misc.debug("resp: %d", new Object[] { Integer.valueOf(result) });
/* 189 */         resp = method.getResponseBodyAsString();
/* 190 */         ZimbraLog.misc.debug("got response from ui node: %s", new Object[] { resp });
/*     */       } catch (IOException e) {
/* 192 */         ZimbraLog.misc.warn("failed to get response from ui node", e);
/*     */       } catch (AuthTokenException e) {
/* 194 */         ZimbraLog.misc.warn("failed to get authToken", e);
/*     */       } finally {
/* 196 */         if (method != null) {
/* 197 */           method.releaseConnection();
/*     */         }
/*     */       }
/* 200 */       if ((authToken != null) && (authToken.isRegistered())) {
/*     */         try {
/* 202 */           authToken.deRegister();
/* 203 */           ZimbraLog.misc.debug("de-registered auth token, isRegistered?%s", new Object[] { Boolean.valueOf(authToken.isRegistered()) });
/*     */         } catch (AuthTokenException e) {
/* 205 */           ZimbraLog.misc.warn("failed to de-register authToken", e);
/*     */         }
/*     */       }
/* 208 */       return resp;
/*     */     }
/* 210 */     return "";
/*     */   }
/*     */   
/*     */   public static void flushUistringsCache() throws ServiceException {
/* 214 */     sendServiceRequestToEveryUiNode("/fromservice/flushuistrings");
/*     */   }
/*     */   
/*     */   public static void sendFlushZimletRequestToUiNode(Server server) throws ServiceException {
/* 218 */     sendServiceRequestToUiNode(server, "/fromservice/flushzimlets");
/*     */   }
/*     */   
/*     */   private static void postToUiNode(Server server, PostMethod method) throws ServiceException {
/* 222 */     AuthToken authToken = AuthProvider.getAdminAuthToken();
/* 223 */     ZimbraLog.zimlet.debug("got admin auth token");
/* 224 */     HttpClient client = ZimbraHttpConnectionManager.getExternalHttpConnMgr().newHttpClient();
/* 225 */     HttpProxyUtil.configureProxy(client);
/*     */     try {
/*     */       try {
/* 228 */         method.addRequestHeader("authtoken", authToken.getEncoded());
/*     */       } catch (AuthTokenException e) {
/* 230 */         ZimbraLog.zimlet.warn(e); return;
/*     */       }
/*     */       
/* 233 */       ZimbraLog.zimlet.debug("connecting to ui node %s", new Object[] { server.getName() });
/* 234 */       int respCode = HttpClientUtil.executeMethod(client, method);
/* 235 */       if (respCode != 200) {
/* 236 */         ZimbraLog.zimlet.warn("operation failed, return code: %d", new Object[] { Integer.valueOf(respCode) });
/*     */       }
/*     */     } catch (Exception e) {
/* 239 */       ZimbraLog.zimlet.warn("operation failed for node %s", server.getName(), e);
/*     */     } finally {
/* 241 */       if (method != null) {
/* 242 */         method.releaseConnection();
/*     */       }
/*     */     }
/* 245 */     if ((authToken != null) && (authToken.isRegistered())) {
/*     */       try {
/* 247 */         authToken.deRegister();
/* 248 */         ZimbraLog.zimlet.debug("de-registered auth token, isRegistered?%s", new Object[] { Boolean.valueOf(authToken.isRegistered()) });
/*     */       } catch (AuthTokenException e) {
/* 250 */         ZimbraLog.zimlet.warn("failed to de-register auth token", e);
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public static void sendDeployZimletRequestToUiNode(Server server, String zimlet, byte[] data) throws ServiceException
/*     */   {
/* 257 */     if (isServerAtLeast8dot5(server)) {
/* 258 */       HttpClient client = ZimbraHttpConnectionManager.getExternalHttpConnMgr().newHttpClient();
/* 259 */       HttpProxyUtil.configureProxy(client);
/* 260 */       PostMethod method = new PostMethod(URLUtil.getServiceURL(server, "/fromservice/deployzimlet", false));
/* 261 */       method.addRequestHeader("Zimlet", zimlet);
/* 262 */       ZimbraLog.zimlet.info("connecting to ui node %s, data size %d", new Object[] { server.getName(), Integer.valueOf(data.length) });
/* 263 */       method.setRequestBody(new ByteArrayInputStream(data));
/* 264 */       postToUiNode(server, method);
/*     */     }
/*     */   }
/*     */   
/*     */   private static boolean isServerAtLeast8dot5(Server server) {
/* 269 */     if (server.getServerVersion() == null) {
/* 270 */       ZimbraLog.misc.info("ui node %s is on version pre 8.5, aborting", new Object[] { server.getName() });
/* 271 */       return false;
/*     */     }
/* 273 */     return true;
/*     */   }
/*     */   
/*     */   public static void sendUndeployZimletRequestToUiNode(Server server, String zimlet) throws ServiceException
/*     */   {
/* 278 */     if (isServerAtLeast8dot5(server)) {
/* 279 */       HttpClient client = ZimbraHttpConnectionManager.getExternalHttpConnMgr().newHttpClient();
/* 280 */       HttpProxyUtil.configureProxy(client);
/* 281 */       PostMethod method = new PostMethod(URLUtil.getServiceURL(server, "/fromservice/undeployzimlet", false));
/* 282 */       method.addRequestHeader("Zimlet", zimlet);
/* 283 */       postToUiNode(server, method);
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/util/WebClientServiceUtil.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */